<template>
    <div class="warp" style="height:100%;">
        <navbar :title="kgData.kbiTitle"></navbar>
        <div style="height: calc(100% - 56px);padding: 56px 0 0 0;">
            <iframe  :src="url" style="height: 100%;" width="100%"  scrolling="yes" frameborder="0" />
        </div>
        <common-loading :isLoading="isLoading"></common-loading>
    </div>
</template>

<script>
export default {
    name: 'docPage',
    data() {
        return {
            kgData: {
                kbiTitle: ''
            },
            url: '',
            isLoading: false
        };
    },
    mounted() {
        this.isLoading = true;
        this.kgData = this.$route.query;
        let url = this.kgData.attachments[0].url;
        let type = url.substring(url.lastIndexOf('.') + 1).toUpperCase();
        if (type === 'TXT') {
            this.url = this.kgData.attachments[0].url;
            this.isLoading = false;
        } else {
            this.$axios({
                method: 'GET',
                url: `/app/idv/previewUrl`,
                params: {
                    filePath: window.unescape(this.kgData.attachments[0].url)
                }
            }).then(res => {
                this.url = res.data;
                this.isLoading = false;
            });
        }
        // this.$axios.get(`/app/api/trainee/kb/item/detail/${kbiId}`).then((res) => {
        //     this.kgData = res.data;
        //     this.$axios({
        //         method: 'GET',
        //         url: `/app/idv/previewUrl`,
        //         params: {
        //             filePath: window.unescape(this.kgData.attachments[0].url)
        //         }
        //     }).then(res => {
        //         this.url = res.data;
        //         this.isLoading = false;
        //     });
        // });
    }
};
</script>

<style scoped>
</style>
